'''
Created on May 22, 2009

@author: Roni
'''

from cliques.potentialBasedSearch import potentialBasedSearch
from cliques.cliqueAlgorithm import cliqueAlgorithm
import random
import pickle

class potentialBasedTester(potentialBasedSearch):
    '''
    classdocs
    '''


    def __init__(self):
        '''
        Constructor
        '''
        potentialBasedSearch.__init__(self)
        
    def choose_node(self):
       return self.generated[random.randint(0,len(self.generated)-1)]

    def clique_found(self):
        result = cliqueAlgorithm.clique_found(self)
        if result==True:
            the_clique = self.clique_finder.find_clique(self.k,\
                self.ckg.neighbors(self.current_node)+[self.current_node])
            for clique in self.pcdb:
                if len(clique.core)==self.k-1:
                    return True
            raise NameError("Problem k-clique not in PCDB")        
        return result
        
    def __str__(self):
        return "potentialBasedTester"
    
    
    